<!DOCTYPE html>
<html>
	<head>
		<title>sample</title>
	</head>

	<body onload="init()">
		<h1 id="status">Hello World.</h1>

		<script src="https://code.createjs.com/soundjs-0.6.2.min.js"></script>

		<script>
			var display;

			function init() {
				display = document.getElementById("status");
				display.addEventListener("click", handleClick, false);
				display.innerHTML = "Touch to Start";
			}

			function handleClick(event) {
				display.removeEventListener("click", handleClick, false);
				var myApp = new myNameSpace.MyApp();
			}

			this.myNameSpace = this.myNameSpace || {};
			(function() {
				// the application
				function MyApp() {
					this.init();
				}

				MyApp.prototype = {
					displayMessage:null,

					init: function() {
						this.displayMessage = document.getElementById("status");

						if (!createjs.Sound.initializeDefaultPlugins()) {return;}

						var audioPath = "../../_assets/audio/";
						var sounds = [
							{id:"Music", src:"M-GameBG.ogg"},
							{id:"Thunder", src:"Thunder1.ogg"}
						];

						this.displayMessage.innerHTML = "loading audio";
						createjs.Sound.alternateExtensions = ["mp3"];
						var loadProxy = createjs.proxy(this.handleLoad, this);
						createjs.Sound.addEventListener("fileload", loadProxy);
						createjs.Sound.registerSounds(sounds, audioPath);
					},

					handleLoad: function(event) {
						createjs.Sound.play(event.src);
						this.displayMessage.innerHTML = "Playing " + event.src;
					}
				}

				myNameSpace.MyApp = MyApp;
			}());
		</script>
	</body>
</html>
